var api = require('../../utils/api.js')
var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        show:0,
        lists:[]
    },

    addlist(){
        wx.switchTab({
          url: '/pages/list/apply',
        })
    },

    //选择分类
    setshow(ret){
        console.log(ret);
        var i=ret.currentTarget.dataset.i;

        this.setData({
            show:i
        })
        this.getmysuqiu();
    },
    getmysuqiu(){
        var that=this;
        var status=this.data.show;

        api.post({
            url: 'orderlist/getmysuqiulist',
            data: {status:status},
            success: data => {
                console.log(data) 

                that.setData({
                    lists:data.data
                })
            }
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.getmysuqiu();
    },

    previewImage(e) {
        console.log(e);
        var id=e.currentTarget.dataset.i;
        var lists=this.data.lists;
        var imgs=lists[id].imgs;

        wx.previewImage({
            current: imgs[0], // 当前显示图片的http链接
            urls: imgs // 需要预览的图片http链接列表
        });

    },
    delete(e){
        console.log(e);
        var id=e.currentTarget.dataset.i;   
        var that=this;

        wx.showModal({
          title: '删除',
          content: '确定要删除此向吗？',
          complete: (res) => {
            if (res.confirm) {
                api.post({
                    url: 'orderlist/deletesuqiu',
                    data: {id:id},
                    success: data => {
                        console.log(data) 
                        wx.showToast({
                          title: data.msg,
                          icon:'none'
                        })
        
                        that.getmysuqiu();
                    }
                })
            }
          }
        })

    },
    //查看详情
    seeinfo(ret){
        console.log(ret);
        var id=ret.currentTarget.dataset.id;

        wx.navigateTo({
          url: '/pages/list/info?id='+id,
        })
    },

    bohui(){
        wx.showToast({
          title: '您的信息被驳回了，请删除后重新提交',
          icon:'none'
        })

    }

})